package article

import (
	"github.com/astaxie/beego/orm"
	"time"
)

type Cate struct {
	Id int `orm:"pk;auto;description(主键)"`
	CateName string `orm:"size(30);description(栏目名称)"`
	Sort int `orm:"description(排序)"`
	IsActive int `orm:"default(1);description(1启用，0停用)"`
	IsDelete int `orm:"default(0);description(1删除，0未删除)"`
	CreateTime time.Time `orm:"auto_now;type(datetime);description(创建时间);null"`
	News []*News `orm:"reverse(many)"`
}

type News struct {
	Id int `orm:"pk;auto;description(主键)"`
	Title string `orm:"size(120);description(文章标题)"`
	ShortTitle string `orm:"size(60);description(简短标题)"`
	Url string `orm:"size(150);description(跳转地址)"`
	IsTop int `orm:"default(0);description(1置顶，0不置顶)"`
	Keys string `orm:"size(200);description(关键字)"`
	PushTime string `orm:"size(150);description(自定义发布时间);null"`
	Pic string `orm:"size(200);description(封面图片)"`
	Mark string `orm:"size(500);description(文章简介)"`
	Content string `orm:"size(5000);description(文章内容)"`
	IsActive int `orm:"default(1);description(1启用，0停用)"`
	IsDelete int `orm:"default(0);description(1删除，0未删除)"`
	CreateTime time.Time `orm:"auto_now;type(datetime);description(创建时间);null"`
    Cate *Cate `orm:"rel(fk)"`
}

//栏目分类
func (a *Cate) TableName() string {
	return "sys_cate"
}
//文章表
func (a *News) TableName() string {
	return "sys_news"
}

func init()  {
	orm.RegisterModel(
		new(Cate),
		new(News),
	)
}
